﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LDIFTestDataGenerator
{
    class Generator
    {

        private static Random random = new Random((int)DateTime.Now.Ticks);

        public String GenerateValue(Type type, int size)
        {

            if (type == typeof(String))
            {
                return GenerateRandomString(size);
            }

            else if (type == typeof(Boolean))
            {
                return GenerateRandomBool();
            }

            else if (type == typeof(int))
            {
                return GenerateRandomInt(size);
            }
            else
                return GenerateRandomString(size);

        }

        public string GenerateRandomString(int size)
        {
            {
                StringBuilder builder = new StringBuilder();
                char ch;
                for (int i = 0; i < size; i++)
                {
                    ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
                    builder.Append(ch);
                }

                return builder.ToString();
            }

        }

        public string GenerateRandomBool()
        {
            return (random.Next(0, 1) == 0).ToString() ;
        }
        
        public string GenerateRandomInt(int size)
        {
             StringBuilder builder = new StringBuilder();
            for (int i = 0; i < size; i++)
            {
               builder.Append(random.Next(0, 9).ToString());
            }
            return builder.ToString();
        }

    }
}
